package cn.johnyu.controller;

import cn.johnyu.mapper.AccountMapper;
import org.example.commons.dto.AccountDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AccountController {
    @Autowired private AccountMapper accountMapper;

    @GetMapping("/accounts")
    public List<AccountDto> findAllAccounts(){
        return accountMapper.findAllAccounts();
    }

    @GetMapping("/accounts/{id}")
    public AccountDto loadAccount(@PathVariable("id") int id){
        return accountMapper.findAccountById(id);
    }
}
